﻿@using Entity.ProjectEnt;
@{
    ViewBag.Title = "QiPiaoIndex";
    Layout = "~/Views/Shared/_Index.cshtml";
    List<CustomerAndThingsNameEntity> kehulist = ViewBag.kehulist;
    List<CustomerAndThingsNameEntity> pingming = ViewBag.pingminglist;
}
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script>
    $(function () {
        gridList();
    });
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Project/GudaoCar/GetGridJsonQiPiao",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                {
                    label: '日期', name: 'QiPiaoTime', width: 120, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue : "未填写";
                    }
                },
                {
                    label: '班次', name: 'QiPiaoOper', width: 40, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue.Banci : "未填写";
                    }
                },
                {
                    label: '调度员', name: 'QiPiaoOper', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue.OperationPersion.F_RealName : "未填写";
                    }
                },

                {
                    label: '车型', name: 'BelongCarriage', width: 60, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue.CarType : "未填写";
                    }
                },
                {
                    label: '车号', name: 'BelongCarriage', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue.CarriageID : "未填写";
                    }
                },
                {
                    label: '所属股道', name: 'BelongPathway', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue.Name : "未填写";
                    }
                },
                {
                    label: '篷布号/封号', name: 'Fenhao', width: 100, align: 'left'
                },
                {
                    label: '发货人', name: 'Customers', width: 80, align: 'left'
                },
                {
                    label: '到站', name: 'ArriveStation', width: 80, align: 'left'
                },
                {
                    label: '品名', name: 'ThingsName', width: 80, align: 'left'
                },
                {
                    label: '件数', name: 'UnitNumber', width: 50, align: 'left'
                },
                {
                    label: '重量', name: 'Weight', width: 50, align: 'left'
                },
                {
                    label: '备注', name: 'Remark', width: 150, align: 'left'
                }
            ],
            pager: "#gridPager",
            sortname: 'QiPiaoTime desc',
            viewrecords: true

        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: {
                    keyword: $("#txt_keyword").val(),
                    StartTime: $("#sTime").val(),
                    EndTime: $("#eTime").val(),
                    carId: $("#txt_carId").val(),
                    arriveStation: $("#txt_ArriveStation").val(),
                    customerName: $("#txt_customerName").val(),
                    pingming: $("#txt_pingming").val()
                },
            }).trigger('reloadGrid');
        });
        $("#btn_export").click(function () {
            var keyword = $("#txt_keyword").val();
            var StartTime = $("#sTime").val();
            var EndTime = $("#eTime").val();
            var carId = $("#txt_carId").val();
            var customerName = $("#txt_customerName").val();
            var arriveStation = $("#txt_ArriveStation").val();
            var customerName = $("#txt_customerName").val();
            var pingming = $("#txt_pingming").val();
            window.location.href = "/Project/GudaoCar/GetExportQipiaoExcell?keyword=" + keyword + "&StartTime=" + StartTime + "&EndTime=" + EndTime
                + "&carId=" + carId + "&customerName=" + customerName + "&arriveStation=" + arriveStation + "&pingming=" + pingming;
        })
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "添加股道",
            url: "/Project/Pathway/Form",
            width: "650px",
            height: "650px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Form",
            title: "修改股道信息",
            url: "/Project/Pathway/Form?keyValue=" + keyValue,
            width: "650px",
            height: "650px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {

        $.deleteForm({
            url: "/Project/Pathway/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Details",
            title: "查看股道详情",
            url: "/Project/Pathway/Details?keyValue=" + keyValue,
            width: "1000px",
            height: "720px",
            btn: null
        });
    }

</script>


<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            @*<a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新增股道</a>*@
        </div>
        @*<div class="operate">*@
        @* <ul class="nav nav-pills">*@
        @*<li class="first">已选中<span>1</span>项</li>*@
        @*<li><a id="NF-edit" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改股道</a></li>
            <li><a id="NF-delete" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除股道</a></li>*@
        @*<li><a id="NF-Details" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看详情</a></li>*@
        @*<li class="split"></li>*@
        @*</ul>*@
        @*<a href="javascript:;" class="close"></a>*@
        @*</div>*@
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td class="formValue">
                    <select class="btn-group" id="txt_pingming" style="padding: 6px; background-image: none; border: 1px solid ; border-radius: 4px;">
                        @if (pingming.Count > 0)
                        {
                            <option value="">所有品名</option>
                            foreach (var item in pingming)
                            {
                                <option value="@item.Name">@item.Name</option>
                            }
                        }
                    </select>
                </td>
                <td class="formValue">
                    <select class="btn-group" id="txt_customerName" style="padding: 6px; background-image: none; border: 1px solid ; border-radius: 4px;">
                        @if (kehulist.Count > 0)
                        {
                            <option value="">所有客户</option>
                            foreach (var item in kehulist)
                            {
                                <option value="@item.Name">@item.Name</option>
                            }
                        }
                    </select>
                </td>
                <td>
                    <div class="input-group" style="padding-left:11px;padding-right:10px;">
                        <input id="txt_ArriveStation" type="text" class="form-control" placeholder="按照到站搜索" style="width: 90px; margin-right:20px;">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="按照股道名模糊搜索" style="width: 110px; margin-right:20px;">
                        <input id="txt_carId" type="text" class="form-control" placeholder="按照车号模糊搜索" style="width: 100px; margin-right:20px;">
                        <input id="sTime" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" placeholder="输入开始查询时间" style="width: 130px; margin-right:20px;">
                        <input id="eTime" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" placeholder="输入结束查询时间" style="width: 130px; margin-right:20px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary active"><i class="fa fa-search"></i></button>
                            <button id="btn_export" style="margin-left:20px;" type="button" class="btn  btn-primary ">
                                <span class="tab">
                                    导
                                </span>
                            </button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<style>
    table tr td {
        padding-left: 15px;
    }
</style>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>



